import {customRef} from 'vue';

export default function(value,second){
    let initValue=value
	let timer

	let msg=customRef((track,trigger)=>{
		return{
			get(){
				track()//调用该函数通知Vue对当前数据进行持续跟踪
				return initValue
			},
			set(value) {
				clearTimeout(timer)
				timer=setTimeout(()=>{
					initValue=value
					trigger()//调用该函数告知Vue当前数据被修改
				},second)
			}
		}
	})
    return {msg}
}